<template>
  <div class="exams-page">
    <div class="page-header">
      <h2>在线考试</h2>
      <p>选择考试类型，开始您的在线考试</p>
    </div>

    <!-- 考试统计 -->
    <div class="stats-section">
      <div class="stats-grid">
        <div class="stat-card">
          <div class="stat-icon">
            <el-icon><Calendar /></el-icon>
          </div>
          <div class="stat-content">
            <h3>{{ examStats.totalTimes }}</h3>
            <p>总考试次数</p>
          </div>
        </div>
        <div class="stat-card">
          <div class="stat-icon">
            <el-icon><Trophy /></el-icon>
          </div>
          <div class="stat-content">
            <h3>{{ examStats.passedTimes }}</h3>
            <p>通过考试</p>
          </div>
        </div>
        <div class="stat-card">
          <div class="stat-icon">
            <el-icon><TrendCharts /></el-icon>
          </div>
          <div class="stat-content">
            <h3>{{ examStats.avgScore }}</h3>
            <p>平均分数</p>
          </div>
        </div>
        <div class="stat-card">
          <div class="stat-icon">
            <el-icon><Clock /></el-icon>
          </div>
          <div class="stat-content">
            <h3>{{ examStats.leastTime }}</h3>
            <p>最近考试</p>
          </div>
        </div>
      </div>
    </div>

    <!-- 考试选择 -->
    <div class="exams-section">
      <div class="section-header">
        <h3>选择考试</h3>
        <div class="filter-controls">
          <el-select v-model="selectedCategory" placeholder="考试分类" @change="filterExams" style="width: 120px; margin-right: 10px;">
              <el-option :label="item.name" :value="item.id" v-for="(item,index) in examTypes" />
            <!--<el-option label="全部" value="all" />-->
            <!--<el-option label="特定技能" value="特定技能" />-->
            <!--<el-option label="JFT" value="JFT" />-->
            <!--<el-option label="JLPT" value="JLPT" />-->
          </el-select>
          <!--<el-select v-model="selectedDifficulty" placeholder="难度等级" style="width: 120px; margin-right: 10px;">-->
            <!--<el-option label="全部" value="all" />-->
            <!--<el-option label="初级" value="初级" />-->
            <!--<el-option label="中级" value="中级" />-->
            <!--<el-option label="高级" value="高级" />-->
          <!--</el-select>-->
          <!--<el-input-->
            <!--v-model="searchKeyword"-->
            <!--placeholder="搜索考试"-->
            <!--style="width: 200px;"-->
            <!--clearable-->
            <!--@keyup.enter="filterExams"-->
          <!--&gt;-->
            <!--<template #prefix>-->
              <!--<el-icon><Search /></el-icon>-->
            <!--</template>-->
          <!--</el-input>-->
        </div>
      </div>

      <div class="exams-grid">
        <div v-for="exam in filteredExams" :key="exam.id" class="exam-card">
          <div class="exam-header">
            <div class="exam-info">
                <h4>{{ exam.examName }}</h4>
                <p>{{ exam.description }}</p>
              <div class="exam-meta">
                <!--<el-tag size="small" type="info">{{ exam.category }}</el-tag>-->
                <el-tag size="small" :type="getDifficultyType(exam.difficulty)">{{ exam.difficulty }}</el-tag>
              </div>
            </div>
          </div>
          
          <div class="exam-details">
            <div class="detail-item">
              <span class="label">考试时长：</span>
              <span class="value">{{ exam.durationMin }}分钟</span>
            </div>
            <div class="detail-item">
              <span class="label">题目数量：</span>
              <span class="value">{{ exam.questionNum }}题</span>
            </div>
            <div class="detail-item">
              <span class="label">及格分数：</span>
              <span class="value">{{ exam.passScore }}分</span>
            </div>
          </div>
          
          <div class="exam-actions">
            <el-button 
              type="primary" 
              size="large" 
              @click="startExamBtn(exam)"
              :loading="startingExam === exam.id"
            >
              开始考试
            </el-button>
            <!--<el-button -->
              <!--type="info" -->
              <!--size="large" -->
              <!--@click="viewExamDetail(exam)"-->
            <!--&gt;-->
              <!--查看详情-->
            <!--</el-button>-->
          </div>
        </div>
      </div>

      <!-- 分页 -->
      <div class="pagination-wrapper">
        <el-pagination
          v-model:current-page="currentPage"
          v-model:page-size="pageSize"
          :page-sizes="[12, 24, 36, 48]"
          :total="totalExams"
          layout="total, sizes, prev, pager, next, jumper"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
    </div>

    <!-- 考试记录 -->
    <div class="history-section">
      <div class="section-header">
        <h3>考试记录</h3>
        <!--<el-button type="primary" @click="viewAllHistory">查看全部记录</el-button>-->
      </div>
      
      <div class="history-table">
        <el-table 
          :data="recentExams" 
          style="width: 100%"
          v-loading="examHistoryLoading"
          element-loading-text="加载中..."
          :empty-text="examHistoryLoading ? '加载中...' : '暂无考试记录'"
        >
          <el-table-column prop="examName" label="考试名称" min-width="200">
            <template #default="scope">
              <div class="exam-name">
                <!--<img :src="scope.row.examIcon" :alt="scope.row.examName" class="exam-icon" />-->
                <div>
                  <div class="exam-title">{{ scope.row.examName }}</div>
                  <!--<div class="exam-type">{{ scope.row.examType }}</div>-->
                </div>
              </div>
            </template>
          </el-table-column>
          

            <el-table-column prop="startedAt" label="考试时间" width="200">
                <template #default="scope">
                {{ getNowDateMin(scope.row.startedAt) }}
                </template>
            </el-table-column>
          <el-table-column prop="score" label="成绩" width="100">
            <template #default="scope">
              <span v-if="scope.row.score" class="score" :class="getScoreClass(scope.row.score)">
                {{ scope.row.score }}分
              </span>
              <span v-else>-</span>
            </template>
          </el-table-column>
          
          <el-table-column prop="result" label="结果" width="100">
            <template #default="scope">
              <el-tag v-if="scope.row.passed" :type="scope.row.passed == '1' ? 'success' : 'danger'">
                {{ scope.row.passed == '1' ? '通过' : '不通过' }}
              </el-tag>
              <span v-else>-</span>
            </template>
          </el-table-column>
          
          <el-table-column label="操作" width="150" fixed="right">
            <template #default="scope">
              <el-button 
                type="primary" 
                size="small"
                @click="viewResult(scope.row)"
              >
                查看详情
              </el-button>
            </template>
          </el-table-column>
        </el-table>
        
        <!-- 考试记录分页 -->
        <div class="pagination-wrapper" style="margin-top: 20px;">
          <el-pagination
            v-model:current-page="examHistoryPage"
            v-model:page-size="examHistoryPageSize"
            :page-sizes="[5, 10, 20, 50]"
            :total="totalExamHistory"
            layout="total, sizes, prev, pager, next, jumper"
            @size-change="handleExamHistorySizeChange"
            @current-change="handleExamHistoryCurrentChange"
            :hide-on-single-page="false"
          />
        </div>
      </div>
    </div>

    <!-- 成绩分析 -->
    <!--<div class="analysis-section">-->
      <!--<div class="section-header">-->
        <!--<h3>成绩分析</h3>-->
      <!--</div>-->
      <!---->
      <!--<div class="analysis-grid">-->
        <!--<div class="analysis-card">-->
          <!--<h4>成绩趋势</h4>-->
          <!--<div class="chart-placeholder">-->
            <!--<el-icon size="60" color="#409EFF"><TrendCharts /></el-icon>-->
            <!--<p>成绩趋势图表</p>-->
          <!--</div>-->
        <!--</div>-->
        <!---->
        <!--<div class="analysis-card">-->
          <!--<h4>考试类型分布</h4>-->
          <!--<div class="chart-placeholder">-->
            <!--<el-icon size="60" color="#67C23A"><PieChart /></el-icon>-->
            <!--<p>考试类型分布图</p>-->
          <!--</div>-->
        <!--</div>-->
        <!---->
        <!--<div class="analysis-card">-->
          <!--<h4>通过率统计</h4>-->
          <!--<div class="pass-rate">-->
            <!--<div class="rate-circle">-->
              <!--<div class="rate-number">{{ passRate }}%</div>-->
              <!--<div class="rate-label">通过率</div>-->
            <!--</div>-->
            <!--<div class="rate-details">-->
              <!--<div class="rate-item">-->
                <!--<span class="label">通过：</span>-->
                <!--<span class="value success">{{ examStats.passedExams }}</span>-->
              <!--</div>-->
              <!--<div class="rate-item">-->
                <!--<span class="label">未通过：</span>-->
                <!--<span class="value danger">{{ examStats.failedExams }}</span>-->
              <!--</div>-->
            <!--</div>-->
          <!--</div>-->
        <!--</div>-->
      <!--</div>-->
    <!--</div>-->

    <!-- 错题集 -->
    <div class="wrong-questions-section">
      <div class="section-header">
        <h3>错题集</h3>
        <el-button type="warning" @click="viewAllWrongQuestions">查看全部错题</el-button>
      </div>
      
      <div class="wrong-questions-grid">
        <div v-for="question in recentWrongQuestions" :key="question.id" class="wrong-question-card">
          <div class="question-header">
            <h4>{{ question.examName }}</h4>
            <el-tag size="small" type="danger">错误{{ question.wrongTimes }}次</el-tag>
          </div>
          <div class="question-content">
            <p>{{ question.content }}</p>
          </div>
          <div class="question-actions">
            <el-button type="primary" size="small" @click="reviewQuestion(question)">
              复习此题
            </el-button>
            <el-button type="info" size="small" @click="viewExplanation(question)">
              查看解析
            </el-button>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, computed, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { ElMessage, ElMessageBox } from 'element-plus'
import { 
  Calendar, 
  Trophy, 
  TrendCharts, 
  Clock, 
  PieChart,
  Search
} from '@element-plus/icons-vue'
import {
  getExamsList,
  getExamDetail,
  startExam,
  getExamHistory,
  getExamStats,
  getWrongQuestions,
  statsExams,
  getQuestionId,
  examstypeList,
} from '@/api/system'
import { getNowDateMin } from '@/utils'



const router = useRouter()
const userInfo =  ref(localStorage.getItem('user') && typeof localStorage.getItem('user') == 'string'? JSON.parse(localStorage.getItem('user')) : {})

// 响应式数据
const selectedCategory = ref('')
const selectedDifficulty = ref('all')
const searchKeyword = ref('')
const currentPage = ref(1)
const pageSize = ref(12)
const loading = ref(false)
const startingExam = ref(null)
const totalExams = ref(0)
const exams = ref([])
const recentExams = ref([])
const recentWrongQuestions = ref([])

// 考试记录分页相关
const examHistoryPage = ref(1)
const examHistoryPageSize = ref(10)
const totalExamHistory = ref(0)
const examHistoryLoading = ref(false)

// 考试统计数据
const examStats = ref({
  totalExams: 0,
  passedExams: 0,
  failedExams: 0,
  averageScore: 0,
  recentExam: '暂无'
})

// 获取考试列表
const fetchExams = async () => {
  loading.value = true
  try {
    const res  = await getExamsList({
      pageNum: currentPage.value,
      pageSize: pageSize.value,
      examTypeId: selectedCategory.value ? String(selectedCategory.value) :''
    })
    // 使用mock数据
    const mockExams = [
      {
        id: 1,
        name: '日语N5基础语法考试',
        description: '测试日语N5级别的基础语法知识，包括助词、动词变化等',
        category: 'JLPT',
        difficulty: '初级',
        duration: 60,
        totalQuestions: 50,
        icon: 'https://via.placeholder.com/80x80/409EFF/FFFFFF?text=N5',
        passScore: 60,
        maxScore: 100
      },
      {
        id: 2,
        name: '商务日语会话考试',
        description: '商务场景下的日语会话能力测试，涵盖日常商务交流',
        category: '特定技能',
        difficulty: '中级',
        duration: 90,
        totalQuestions: 60,
        icon: 'https://via.placeholder.com/80x80/67C23A/FFFFFF?text=商务',
        passScore: 70,
        maxScore: 100
      },
      {
        id: 3,
        name: '日语听力理解考试',
        description: '测试日语听力理解能力，包括日常对话和新闻听力',
        category: 'JLPT',
        difficulty: '中级',
        duration: 75,
        totalQuestions: 40,
        icon: 'https://via.placeholder.com/80x80/E6A23C/FFFFFF?text=听力',
        passScore: 65,
        maxScore: 100
      },
      {
        id: 4,
        name: 'JFT基础考试',
        description: '日本语能力测试基础级别，适合初学者',
        category: 'JFT',
        difficulty: '初级',
        duration: 45,
        totalQuestions: 30,
        icon: 'https://via.placeholder.com/80x80/F56C6C/FFFFFF?text=JFT',
        passScore: 55,
        maxScore: 100
      },
      {
        id: 5,
        name: '日语写作表达考试',
        description: '测试日语写作表达能力，包括短文写作和邮件写作',
        category: '特定技能',
        difficulty: '高级',
        duration: 120,
        totalQuestions: 80,
        icon: 'https://via.placeholder.com/80x80/909399/FFFFFF?text=写作',
        passScore: 75,
        maxScore: 100
      },
      {
        id: 6,
        name: '日语阅读理解考试',
        description: '测试日语阅读理解能力，包括文章阅读和问题解答',
        category: 'JLPT',
        difficulty: '中级',
        duration: 90,
        totalQuestions: 70,
        icon: 'https://via.placeholder.com/80x80/409EFF/FFFFFF?text=阅读',
        passScore: 70,
        maxScore: 100
      }
    ]
    
    // 模拟筛选
//    let filtered = mockExams
//    if (selectedCategory.value !== 'all') {
//      filtered = filtered.filter(e => e.category === selectedCategory.value)
//    }
//    if (selectedDifficulty.value !== 'all') {
//      filtered = filtered.filter(e => e.difficulty === selectedDifficulty.value)
//    }
//    if (searchKeyword.value) {
//      filtered = filtered.filter(e =>
//        e.name.toLowerCase().includes(searchKeyword.value.toLowerCase()) ||
//        e.description.toLowerCase().includes(searchKeyword.value.toLowerCase())
//      )
//    }
//
//    // 模拟分页
//    const start = (currentPage.value - 1) * pageSize.value
//    const end = start + pageSize.value
//    exams.value = filtered.slice(start, end)
//    totalExams.value = filtered.length
    exams.value = res.rows
    totalExams.value = res.total
    
  } catch (error) {
    console.error('获取考试列表失败:', error)
    ElMessage.error('获取考试列表失败，请稍后重试')
  } finally {
    loading.value = false
  }
}

const examTypes = ref([])
// 获取考试类型
const fetchLists = async () => {
  try {
    const params = {
      pageNum: 1,
      pageSize: 100,
    }

    const response = await examstypeList(params)
    if (response.code === 200) {
      examTypes.value = response.rows || []
    } else {
    }
  } catch (error) {
    console.error('获取考试类型列表失败:', error)
  } finally {
  }
}
// 获取考试统计
const fetchExamStats = async () => {
//  try {

    const res  = await statsExams({
      userId : userInfo.value?.userId
    })
    examStats.value = res.data
    // 使用mock数据
//    examStats.value = {
//      totalExams: 15,
//      passedExams: 12,
//      failedExams: 3,
//      averageScore: 78,
//      recentExam: '2024-01-15'
//    }
//  } catch (error) {
//    console.error('获取考试统计失败:', error)
//  }
}

// 获取最近考试记录
const fetchRecentExams = async () => {
  try {
    examHistoryLoading.value = true
    const res = await getExamHistory({
      pageNum: examHistoryPage.value,
      pageSize: examHistoryPageSize.value,
      userId: userInfo.value?.userId
    })
    if (res && res.rows) {
      recentExams.value = res.rows
      totalExamHistory.value = res.total || 0
    } else {
      recentExams.value = []
      totalExamHistory.value = 0
    }
  } catch (error) {
    console.error('获取最近考试记录失败:', error)
    ElMessage.error('获取考试记录失败，请稍后重试')
    recentExams.value = []
    totalExamHistory.value = 0
  } finally {
    examHistoryLoading.value = false
  }
}

// 获取最近错题
const fetchRecentWrongQuestions = async () => {
  try {
    const res  = await getWrongQuestions({
      examId:'',
      examTypeId: '',
      wrongNums: '',
      pageNum: 1,
      pageSize: 4,
    })
//    recentWrongQuestions.value = [
//      {
//        id: 1,
//        examName: '日语N5基础语法考试',
//        question: {
//          content: '「は」和「が」的区别是什么？',
//          correctAnswer: '「は」表示主题，「が」表示主语',
//          explanation: '「は」用于提示主题，表示要谈论的话题；「が」用于表示动作的主体或状态的主体。'
//        },
//        userAnswer: '「は」表示主语，「が」表示主题',
//        wrongCount: 2
//      },
//      {
//        id: 2,
//        examName: '商务日语会话考试',
//        question: {
//          content: '在商务场合，如何礼貌地拒绝邀请？',
//          correctAnswer: '「申し訳ございませんが、今回は参加できません」',
//          explanation: '在商务场合，应该使用敬语表达歉意，并说明无法参加的原因。'
//        },
//        userAnswer: '「参加しません」',
//        wrongCount: 1
//      },
//      {
//        id: 3,
//        examName: '日语听力理解考试',
//        question: {
//          content: '听力材料中提到的会议时间是？',
//          correctAnswer: '下午2点',
//          explanation: '听力材料中明确提到了「午後2時」这个时间。'
//        },
//        userAnswer: '上午10点',
//        wrongCount: 3
//      },
//      {
//        id: 4,
//        examName: '日语阅读理解考试',
//        question: {
//          content: '文章的主要观点是什么？',
//          correctAnswer: '环保意识的重要性',
//          explanation: '文章通过多个例子说明了环保意识在现代社会中的重要性。'
//        },
//        userAnswer: '经济发展的必要性',
//        wrongCount: 1
//      }
//    ]
    recentWrongQuestions.value = res.rows
  } catch (error) {
    console.error('获取错题集失败:', error)
  }
}

// 计算属性
const filteredExams = computed(() => {
  let filtered = exams.value

//  // 按分类筛选
//  if (selectedCategory.value !== 'all') {
//    filtered = filtered.filter(e => e.category === selectedCategory.value)
//  }
//
//  // 按难度筛选
//  if (selectedDifficulty.value !== 'all') {
//    filtered = filtered.filter(e => e.difficulty === selectedDifficulty.value)
//  }
//
//  // 按关键词搜索
//  if (searchKeyword.value) {
//    filtered = filtered.filter(e =>
//      e.name.toLowerCase().includes(searchKeyword.value.toLowerCase()) ||
//      e.description.toLowerCase().includes(searchKeyword.value.toLowerCase())
//    )
//  }

  return filtered
})

const passRate = computed(() => {
  if (examStats.value.totalExams === 0) return 0
  return Math.round((examStats.value.passedExams / examStats.value.totalExams) * 100)
})

// 获取难度类型
const getDifficultyType = (difficulty) => {
  switch (difficulty) {
    case '初级': return 'success'
    case '中级': return 'warning'
    case '高级': return 'danger'
    default: return 'info'
  }
}

// 获取成绩样式类
const getScoreClass = (score) => {
  if (score >= 90) return 'excellent'
  if (score >= 80) return 'good'
  if (score >= 70) return 'pass'
  return 'fail'
}

// 筛选考试
const filterExams = () => {
  currentPage.value = 1
  fetchExams()
}

// 开始考试
const startExamBtn = async (exam) => {
  try {
    await ElMessageBox.confirm(
      `确定要开始"${exam.name}"考试吗？\n考试时长：${exam.duration}分钟\n题目数量：${exam.totalQuestions}题`,
      '开始考试',
      {
        confirmButtonText: '开始考试',
        cancelButtonText: '取消',
        type: 'info'
      }
    )
    
    startingExam.value = exam.id
    
    // 模拟考试开始成功
    ElMessage.success('考试开始成功！')
    
    // 跳转到考试页面
    router.push({
      path: '/exam-room',
      query: { 
        sessionId: `session_${Date.now()}`,
        examId: exam.id
      }
    })
    
  } catch (error) {
    if (error !== 'cancel') {
      console.error('开始考试失败:', error)
      ElMessage.error('开始考试失败，请稍后重试')
    }
  } finally {
    startingExam.value = null
  }
}

// 查看考试详情
const viewExamDetail = (exam) => {
  router.push(`/exam-detail/${exam.id}`)
}

// 查看考试结果
const viewResult = (exam) => {
  router.push({
    path: '/exam-result',
    query: { resultId: exam.id}
  })
}

// 查看全部记录
const viewAllHistory = () => {
  router.push('/exam-history')
}

// 查看全部错题
const viewAllWrongQuestions = () => {
  router.push('/wrong-questions')
}

// 复习错题
const reviewQuestion = (question) => {
  router.push({
    path: '/question-review',
    query: { questionId: question.questionId,userAnswer: question.wrongAnswer }
  })
}

const changeSelect  = (str)=>{
  switch (str) {
    case 'A':
      return 'option_a'
    case 'B':
      return 'option_b'
    case 'C':
      return 'option_c'
    case 'D':
      return 'option_d'
    default:
      return ''
  }

}

// 查看解析
const viewExplanation = async(obj) => {
  const res  = await getQuestionId(obj.questionId)

  const userAnswer = obj.wrongAnswer + ' ' +res?.data?.[changeSelect(obj.wrongAnswer)]
  const correctAnswer= res?.data?.answer + ' ' +res?.data?.[changeSelect(res?.data?.answer)]
  ElMessageBox.alert(
    `<div><strong>题目：</strong>${res?.data?.content}</div><br>
     <div><strong>正确答案：</strong>${correctAnswer}</div><br>
     <div><strong>您的答案：</strong>${userAnswer}</div><br>
     <div><strong>解析：</strong>${res?.data?.remark || '暂无解析'}</div>`,
    '题目解析',
    {
      dangerouslyUseHTMLString: true,
      confirmButtonText: '确定'
    }
  )
}

const handleSizeChange = (size) => {
  pageSize.value = size
  currentPage.value = 1
  fetchExams()
}

const handleCurrentChange = (page) => {
  currentPage.value = page
  fetchExams()
}

// 考试记录分页处理
const handleExamHistorySizeChange = (size) => {
  examHistoryPageSize.value = size
  examHistoryPage.value = 1
  fetchRecentExams()
}

const handleExamHistoryCurrentChange = (page) => {
  examHistoryPage.value = page
  fetchRecentExams()
}

onMounted(() => {
  // 初始化数据
  fetchLists()
  fetchExams()
  fetchExamStats()
  fetchRecentExams()
  fetchRecentWrongQuestions()
})
</script>

<style scoped>
.exams-page {
  min-height: 100vh;
  background: #f5f7fa;
  padding: 20px 0;
}

.page-header {
  text-align: center;
  margin-bottom: 30px;
}

.page-header h2 {
  color: #2c3e50;
  margin: 0 0 10px 0;
  font-size: 2rem;
}

.page-header p {
  color: #666;
  margin: 0;
  font-size: 1.1rem;
}

.stats-section {
  max-width: 1200px;
  margin: 0 auto 40px;
  padding: 0 20px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: center;
  gap: 20px;
}

.stat-icon {
  font-size: 2.5rem;
  color: #409EFF;
}

.stat-content h3 {
  margin: 0 0 5px 0;
  font-size: 1.2rem;
  color: #2c3e50;
}

.stat-content p {
  margin: 0;
  color: #666;
  font-size: 0.9rem;
}

.exams-section {
  max-width: 1200px;
  margin: 0 auto 40px;
  padding: 0 20px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

.section-header h3 {
  margin: 0;
  color: #2c3e50;
  font-size: 1.5rem;
}

.filter-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.exams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 25px;
}

.exam-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.exam-header {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
}

.exam-icon {
  width: 60px;
  height: 60px;
  border-radius: 8px;
  object-fit: cover;
}

.exam-info h4 {
  margin: 0 0 5px 0;
  color: #2c3e50;
  font-size: 1.2rem;
}

.exam-info p {
  margin: 0;
  color: #666;
  font-size: 0.9rem;
}

.exam-meta {
  margin-top: 10px;
  display: flex;
  gap: 8px;
}

.exam-details {
  margin-bottom: 20px;
  padding-bottom: 15px;
  border-bottom: 1px solid #eee;
}

.detail-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: #555;
}

.detail-item .label {
  font-weight: 500;
  color: #333;
}

.detail-item .value {
  font-weight: bold;
  color: #2c3e50;
}

.exam-actions {
  display: flex;
  gap: 10px;
  margin-top: 15px;
}

.pagination-wrapper {
  text-align: center;
  margin-top: 30px;
}

.pagination-wrapper .el-pagination {
  justify-content: center;
}

.pagination-wrapper .el-pagination .el-pagination__total {
  margin-right: 16px;
}

.pagination-wrapper .el-pagination .el-pagination__sizes {
  margin-right: 16px;
}

.history-section {
  max-width: 1200px;
  margin: 0 auto 40px;
  padding: 0 20px;
}

.history-table {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.history-table .exam-name {
  display: flex;
  align-items: center;
  gap: 12px;
}

.history-table .exam-icon {
  width: 40px;
  height: 40px;
  border-radius: 6px;
}

.history-table .exam-title {
  font-weight: 500;
  color: #2c3e50;
}

.history-table .exam-type {
  font-size: 0.8rem;
  color: #666;
  margin-top: 2px;
}

.analysis-section {
  max-width: 1200px;
  margin: 0 auto 40px;
  padding: 0 20px;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  gap: 25px;
}

.analysis-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.analysis-card h4 {
  margin: 0 0 20px 0;
  color: #2c3e50;
  font-size: 1.2rem;
}

.chart-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 200px;
  background: #f8f9fa;
  border-radius: 8px;
  color: #666;
}

.chart-placeholder p {
  margin: 10px 0 0 0;
  font-size: 0.9rem;
}

.pass-rate {
  display: flex;
  align-items: center;
  gap: 30px;
}

.rate-circle {
  text-align: center;
  flex-shrink: 0;
}

.rate-number {
  font-size: 2.5rem;
  font-weight: bold;
  color: #67C23A;
}

.rate-label {
  font-size: 0.9rem;
  color: #666;
  margin-top: 5px;
}

.rate-details {
  flex: 1;
}

.rate-item {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
}

.rate-item .label {
  color: #666;
}

.rate-item .value {
  font-weight: bold;
}

.rate-item .value.success {
  color: #67C23A;
}

.rate-item .value.danger {
  color: #F56C6C;
}

.wrong-questions-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

.wrong-questions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 25px;
}

.wrong-question-card {
  background: white;
  border-radius: 12px;
  padding: 25px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.question-header h4 {
  margin: 0 0 5px 0;
  color: #2c3e50;
  font-size: 1.1rem;
}

.question-content p {
  margin: 0 0 15px 0;
  color: #333;
  font-size: 0.95rem;
  line-height: 1.6;
}

.question-actions {
  display: flex;
  gap: 10px;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .exams-grid {
    grid-template-columns: 1fr;
  }
  
  .analysis-grid {
    grid-template-columns: 1fr;
  }
  
  .wrong-questions-grid {
    grid-template-columns: 1fr;
  }
  
  .exam-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .pass-rate {
    flex-direction: column;
    text-align: center;
  }
  
  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }
  
  .pagination-wrapper .el-pagination {
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .pagination-wrapper .el-pagination .el-pagination__sizes {
    margin: 10px 0;
    width: 100%;
    text-align: center;
  }
}
</style> 